package com.tj.collection.enums;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: sm
 * Date: 2017/3/3
 * Time: 上午10:54
 * 亲属枚举
 */
public enum UserContactFamilyTypeEnum {
    MOTHER(1, "Mother"),
    Brother(2, "Brother"),
    Spouse_OR_Partner(3, "Spouse/Partner"),
    FATHER(6, "Father"),
    SISTERS(7, "Sister"),
    Cousin(8, "Cousin"),
    ;

    private Integer type;
    private String desc;

    UserContactFamilyTypeEnum(Integer type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public Integer getType() {
        return type;
    }

    public UserContactFamilyTypeEnum setType(Integer type) {
        this.type = type;
        return this;
    }

    public String getDesc() {
        return desc;
    }

    public UserContactFamilyTypeEnum setDesc(String desc) {
        this.desc = desc;
        return this;
    }

    public static List<String> getDescList() {
        List<String> list = new ArrayList<>();
        for (UserContactFamilyTypeEnum enumObj : UserContactFamilyTypeEnum.values()) {
            list.add(enumObj.getDesc());
        }
        return list;
    }

    public static UserContactFamilyTypeEnum getEnumByType(Integer type) {
        UserContactFamilyTypeEnum userContactFamilyTypeEnum = null;
        for (UserContactFamilyTypeEnum enumObj : UserContactFamilyTypeEnum.values()) {
            if (enumObj.getType().equals(type)) {
                userContactFamilyTypeEnum = enumObj;
                break;
            }
        }

        return userContactFamilyTypeEnum;
    }

    public static UserContactFamilyTypeEnum getEnumByDesc(String desc) {
        UserContactFamilyTypeEnum userContactFamilyTypeEnum = null;
        for (UserContactFamilyTypeEnum enumObj : UserContactFamilyTypeEnum.values()) {
            if (enumObj.getDesc().equals(desc)) {
                userContactFamilyTypeEnum = enumObj;
                break;
            }
        }
        return userContactFamilyTypeEnum;
    }
}
